
/* JS EXTENSION
 * setDestinee.js
 */


jQuery(document).ready(function(){
    flg_apm.setDestinee.init();
    f=$('#do_sending_test');
    flg_apm.setDestinee.initClicks();
//$(f).val('');
});


flg_apm.setDestinee=new flg_apm.setField('setDestinee','.c_setDestinee');


flg_apm.setDestinee.during_create=function(fi,obj){
//
fi.str=fi.str.replace(/{{selDestPlaceHold}}/g, 'Input free email, select a destinee above or input some letters to autosearch by name/email ');
    return fi;
}
flg_apm.setDestinee.postcreate=function(fi,obj){
    flg_apm.setDestinee.initClicks();

}

var gloWin;
flg_apm.setDestinee.actionPicknext=function(obj){
    gloWin.modal('hide');
    alert('DEV: do add the selected user to the Destinne window');
}
flg_apm.setDestinee.DestineePickEmail=function(obj){
    gloWin= flg_apm.c_create_globalModalWin();
    var cont=my_extensions_views['setDest_pickEmails'].tpl;
    label=$(obj).attr('data-label');
    labelsing=$(obj).attr('data-labelsing');

    cont=cont.replace(/{{label}}/g, label);
    cont=cont.replace(/{{labelsing}}/g, labelsing);
    placeholdercase=' name, email';
    if(label=='Mailing Lists'){
        placeholdercase=' name';
    }else{
    }
    cont=cont.replace(/{{placeholdercase}}/g, placeholdercase);
    flg_apm.c_init_globalModalWin(gloWin,{
        title:"Pick "+label+" emails",
        actionTitle:'Add selection to list',
        content:cont,
        actionClass:'actionPicknext'
    });

    gloWin.modal('show');

    if(label=='Mailing Lists'){
        $('.orimbbycoutnlab').hide();
        $('.orimbbycoutnsel').hide();
    }else{
        $('.orimbbycoutnlab').show();
        $('.orimbbycoutnsel').show();
    }
    flg_apm.initMainRollover();
    flg_apm.setModuleGridLeftPan.initGlobalClicks();
    flg_apm.setDestinee.initClicks();
}

flg_apm.setDestinee.initClicks=function(){
    $('.actionPicknext').off('click').on('click',function(){
        flg_apm.setDestinee.actionPicknext();
    });
    $('.ori_do_pickEmails').off('click').on('click',function(){
        flg_apm.setDestinee.DestineePickEmail(this);
    });


}
